package service.impl;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import model.User;
import service.UserService;

import java.util.List;

/**
 * @author gzp
 * @create 2022-12-13 8:51
 */
public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();

    @Override
    public boolean insert(User user) {
        return userDao.insert(user) == 1;
    }

    @Override
    public boolean delete(int id) {
        return userDao.delete(id) == 1;
    }

    @Override
    public boolean update(User user) {
        return userDao.update(user) == 1;
    }

    @Override
    public User findById(long id) {
        return userDao.findById(id);
    }

    @Override
    public List<User> findAll(int pageIndex, int pageSize) {
        return userDao.findAll(pageIndex, pageSize);
    }

    @Override
    public int pageCount() {
        return userDao.pageCount();
    }

    @Override
    public int findByName(String name) {
        return userDao.findByName(name);
    }

    @Override
    public int findByPhone(String phone) {
        return userDao.findByPhone(phone);
    }

    @Override
    public int findByEmile(String email) {
        return userDao.findByEmile(email);
    }

    @Override
    public List<User> findByPartName(String partName, int pageIndex, int pageSize) {
        return userDao.findByPartName(partName, pageIndex, pageSize);
    }

    @Override
    public User login(String username, String password) {
        return userDao.login(username, password);
    }

    @Override
    public int pageCountByName(String username) {
        return userDao.pageCountByName(username);
    }


    @Override
    public int findIdByName(String username) {
        return userDao.findIdByName(username);
    }


}
